package com.quikin.persistence.jpa.controller.aa;

import java.util.Collection;

import com.von.platform.orm.Command;
import com.von.platform.orm.IPersistenceManager;
import com.von.platform.orm.PersistenceManagerFactory;
import com.von.platform.orm.QueryCommand;
import com.von.platform.orm.TransactionException;

public class AbstractController {

    protected Object find(QueryCommand key) throws TransactionException {
        IPersistenceManager pm = PersistenceManagerFactory.getInstance().getCurrentPM();
        return pm.getByKey(key);
    }

    protected Collection<? extends Object> findCustom(QueryCommand query) throws TransactionException {
        IPersistenceManager pm = PersistenceManagerFactory.getInstance().getCurrentPM();
        return pm.query(query);
    }
    
    public void update(Object obj) throws TransactionException {
        IPersistenceManager pm = PersistenceManagerFactory.getInstance().getCurrentPM();
        Command cmd = new Command();
        cmd.setEntity(obj);
        pm.update(cmd);
    }
}
